return dunder_init
+ def get_limited_abi_version(self):
+ """ Return the version number of the limited ABI to use. """
+
+ # We use PyWeakref_GetObject() which was removed from the limited API
+ # in Python v3.15. It's replacement, PyWeakref_GetRef() was added to
+ # the limited ABI in Python v3.13.
+ return (3, 13, 0) if sys.hexversion >= 0x030f0000 else None
+
def get_options(self):
""" Return the sequence of configurable options. """
static qpycore_pyqtProperty *clone(qpycore_pyqtProperty *orig)
{
qpycore_pyqtProperty *pp = (qpycore_pyqtProperty *)PyType_GenericNew(
- Py_TYPE(orig), 0, 0);
+ Py_TYPE((PyObject *)orig), 0, 0);
if (pp)
{
else
{
// Use the value we have if one wasn't supplied.
- if (!self)
+ if (self)
+ Py_INCREF(self);
+ else
self = instance();
// If self is NULL then we didn't have a method in the first place.
// See if the instance has gone (which isn't an error).
if (self == Py_None)
+ {
+ Py_DECREF(self);
return PyQtSlot::Ignored;
+ }
// If the receiver wraps a C++ object then ignore the call if it no
// longer exists.
if (!no_receiver_check && PyObject_TypeCheck(self, sipSimpleWrapper_Type) && !sipGetAddress((sipSimpleWrapper *)self))
+ {
+ Py_DECREF(self);
return PyQtSlot::Ignored;
+ }
sipMethodDef callable_m;
callable_m.pm_self = self;
callable = sipFromMethod(&callable_m);
+ Py_DECREF(self);
}
// Convert the C++ arguments to Python objects.
if (other)
return false;
- return (mfunc == callable_m.pm_function && instance() == callable_m.pm_self);
+ PyObject *instance_obj = instance();
+ bool res = (mfunc == callable_m.pm_function && instance_obj == callable_m.pm_self);
+ Py_XDECREF(instance_obj);
+
+ return res;
}
if (!other)
}
-// Get the instance object.
+// Get a strong reference to the instance object, otherwise return NULL or a
+// strong referenc to Py_None.
PyObject *PyQtSlot::instance() const
{
+ PyObject *instance_obj;
+
// Use the weak reference if possible.
if (mself_wr)
- return PyWeakref_GetObject(mself_wr);
+ {
+#if PY_VERSION_HEX >= 0x030f0000
+ if (PyWeakref_GetRef(mself_wr, &instance_obj) < 0)
+ instance_obj = NULL;
+#else
+ instance_obj = PyWeakref_GetObject(mself_wr);
+ Py_XINCREF(instance_obj);
+#endif
+ }
+ else
+ {
+ instance_obj = mself;
+ Py_XINCREF(instance_obj);
+ }
- return mself;
+ return instance_obj;
}
const QMetaObject *qpycore_qobject_metaobject(sipSimpleWrapper *pySelf,
sipTypeDef *base)
{
- sipWrapperType *wt = (pySelf ? (sipWrapperType *)Py_TYPE(pySelf) : 0);
+ sipWrapperType *wt = (pySelf ? (sipWrapperType *)Py_TYPE((PyObject *)pySelf) : 0);
return qpycore_get_qmetaobject(wt, base);
}
if (!pySelf)
return -1;
- return qt_metacall_worker(pySelf, Py_TYPE(pySelf), base, _c, _id, _a);
+ return qt_metacall_worker(pySelf, Py_TYPE((PyObject *)pySelf), base, _c,
+ _id, _a);
}
// We only need to look at the MRO if the object is a wrapped type (rather
// than a user sub-class).
- if (base_pytype != Py_TYPE(pySelf))
+ if (base_pytype != Py_TYPE((PyObject *)pySelf))
{
- PyObject *mro = PyObject_GetAttr((PyObject *)Py_TYPE(pySelf),
- qpycore_dunder_mro);
+ PyObject *mro = PyObject_GetAttr(
+ (PyObject *)Py_TYPE((PyObject *)pySelf), qpycore_dunder_mro);
Q_ASSERT(mro);
for (Py_ssize_t i = 0; i < PyTuple_Size(mro); ++i)